<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="Bookmark" href="../imgs/bai.ico">
    <link rel="Shortcut Icon" href="../imgs/bai.ico"/>
    <link rel="stylesheet" type="text/css" href="../css/view.css"/>
    <title>工作台</title>
    <style type="text/css">
        body { margin: 0; background: #efefef; }
        #tbody { margin: 50px 2%; margin-bottom: 100px; height: 85vh; overflow: auto; }
        #tbody .fgroup { padding: 10px; background: #fff; border: 1px solid #ddd; border-radius: 5px; }
        #tbody .group { padding: 5px; padding-bottom: 10px; }
        #tbody .title { color: #555; }
        #tbody .fchild { background: #efefef; }
        #tbody .fedit { margin: 0 5px; color: #0088CC; float: right; }
        #tbody .fdel { margin: 0 5px; color: red; float: right; }
        #tbody input, #tbody select { margin-top: 5px; padding: 10px; width: 100%; border: 1px solid #ddd; border-radius: 3px; }
        #tbody .group button { margin: 0 20%; padding: 10px 0; width: 60%; background: #fff; border: 1px solid #ccc; border-radius: 5px; color: #888; }
        #fbtn { padding: 5px 5vw; width: 90vw; background: #fff; position: fixed; bottom: 0; left: 0; z-index: 10; }
        #fbtn button { margin: 10px 0; margin-left: 5%; padding: 8px 0; width: 40%; border: none; border-radius: 5px; background: #0088CC; color: #fff; }
    </style>
</head>
<body>
<!--顶部-->
<div id="header">
    <div class="zjt" onclick="history.go(-1);">
        <img src="../imgs/icon-zjt.png"/>
    </div>
    <div class="title">工时录入</div>
</div>

<!--主体-->
<div id="tbody">
    <div class="fgroup">
        <div class="group">
            <div class="title">
                <span style="color: red;">*</span>
                员工：
            </div>
            <!-- <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'in_day\')||\'%y-%M-%d\'}'})" id="in_day" class="input-text Wdate" readonly/> -->
            <input type="text" class="input-text" id="uname" readonly/>
        </div>
        <div class="group">
            <div class="title">原密码：</div>
            <input type="password" class="input-text" id="upwd" placeholder="输入原密码"/>
        </div>
        <div class="group">
            <div class="title">新密码：</div>
            <input type="password" class="input-text" id="pwdnew" placeholder="输入新密码"/>
        </div>
        <div class="group">
            <div class="title">重复密码：</div>
            <input type="password" class="input-text" id="pwdnew2" placeholder="重复密码"/>
        </div>
    </div>
</div>
<div id="fbtn">
    <button onclick="setModify();">更新密码</button>
    <button style="background: orangered;" onclick="toClose();">取 消</button>
</div>


<!--编辑弹窗-->
<div id="formPop"></div>
<!--信息弹窗-->
<div id="msgPop"></div>
</body>
</html>


<script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="../../admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../js/view.js"></script>
<!-- <script type="text/javascript" src="../js/ws-wh/whyw-edit.js"></script> -->
<script type="text/javascript">
    // var cw = document.documentElement.clientWidth;
    // var ch = document.documentElement.clientHeight;
    var preUrl = getParamByUrl('preUrl');
    (function () {
        getUinfo();
    })();
    // 获取用户信息
    function getUinfo(){
        var uinfo = getUserInfo();
        $('#uname')[0].value = uinfo.uname;
    }
    // 更新密码
    function setModify(){
        var uinfo = getUserInfo();
        var formData = {
            id: uinfo.uid,
            upwd: $('#upwd').val(),
            pwdnew: $('#pwdnew').val(),
            pwdnew2: $('#pwdnew2').val(),
        };
        if (formData.upwd == '') {
            msgPop({msg: '密码必须的'}); return
        }
        if (formData.pwdnew == '') {
            msgPop({msg: '新密码必须的'}); return
        }
        if (formData.pwdnew2 == '') {
            msgPop({msg: '确认密码必须的'}); return
        }
        if (formData.pwdnew != formData.pwdnew2) {
            msgPop({msg: '2次新密码不一致'}); return
        }
        $.ajax({
            type: 'post',
            url: apiDomain + 'staff/pwd-set',
            data: formData,
            success: function (res) {
                console.log(res);
                if (res.code < 0) {
                    msgPop({msg: res.msg});
                    return
                }
                msgPop({msg: '成功'});
                setTimeout(function(){
                    logout();
                }, 500);
            },
            error: function () {
                console.log('网络错误');
            }
        });
    }
    // 关闭
    function toClose(){
        window.location.href = preUrl;
    }
</script>